package com.example.datasourceprimordialdemo2.service.impl;


import com.example.datasourceprimordialdemo2.dao.UserCopyDao;
import com.example.datasourceprimordialdemo2.dao.UserDao;
import com.example.datasourceprimordialdemo2.datasource.annotation.DataSource;
import com.example.datasourceprimordialdemo2.datasource.enums.DataSourceType;
import com.example.datasourceprimordialdemo2.entity.User;
import com.example.datasourceprimordialdemo2.entity.UserCopy;
import com.example.datasourceprimordialdemo2.service.UserCopyService;
import com.example.datasourceprimordialdemo2.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (User)表服务实现类
 *
 * @author makejava
 * @since 2022-11-08 11:00:44
 */
@Service("UserCopyService")
public class UserCopyServiceImpl implements UserCopyService {
    @Resource
    private UserCopyDao userCopyDao;


    @Override
    public List<UserCopy> query() {
        return userCopyDao.selectList(null);
    }

    /**
     * 新增数据
     *
     * @param user 实例对象
     * @return 实例对象
     */
    @Override
    @DataSource(DataSourceType.SLAVE1)
    public UserCopy insert(UserCopy user) {
        this.userCopyDao.insert(user);
        return user;
    }
}
